  customMetrics
  | where timestamp > ago(30m)
  | where name == "gen_ai.client.token.usage"
  | project timestamp, name, value,
      tokenType   = customDimensions["gen_ai.token.type"],
      operation_Id
  | order by timestamp desc
  https://dev-containerapp-igentic.icydune-1fe4b6f9.centralus.azurecontainerapps.io/api/iGenticAutonomousAgent/Executor/44a6360a-e30f-4c76-b417-8a9ed2fc2831
  
  
  Root Cause — This is a Preview Limitation

  I found it in the official docs. The Token usage column in Foundry's list/inventory view is only supported for      
  native Foundry agents, not custom registered agents:

  ┌────────────────┬────────────────────────┐
  │     Column     │   Supported Platform   │
  ├────────────────┼────────────────────────┤
  │ Token usage    │ Foundry (native) only  │
  ├────────────────┼────────────────────────┤
  │ Estimated cost │ Foundry (native) only  │
  ├────────────────┼────────────────────────┤
  │ Error rate     │ All (including Custom) │
  ├────────────────┼────────────────────────┤
  │ Runs           │ All (including Custom) │
  └────────────────┴────────────────────────┘

  The invoke_agent in the list will always show as the operation — that's the APIM root span name that Foundry        
  generates for every custom agent call. You cannot change this. It is not your code's doing.

  ---
  What IS Actually Working ✅

  Your implementation is correct. Proof:

  ┌────────────────────────────────────────┬─────────────────────────────────────────────────────────┬───────────┐    
  │                 Where                  │                      What you see                       │  Status   │    
  ├────────────────────────────────────────┼─────────────────────────────────────────────────────────┼───────────┤    
  │ App Insights KQL (screenshot 12)       │ create_agent with igentic-autonomous-agent, 10679/1435  │ ✅        │     
  │                                        │ tokens                                                  │ Working   │    
  ├────────────────────────────────────────┼─────────────────────────────────────────────────────────┼───────────┤    
  │ Trace detail view (screenshot 14       │ "Create Agent  create_agent ✅  12114t"                 │ ✅        │      
  │ bottom)                                │                                                         │ Working   │    
  ├────────────────────────────────────────┼─────────────────────────────────────────────────────────┼───────────┤    
  │ _MS.ProcessedByMetricExtractors: X     │ App Insights metric extractor processed your span       │ ✅        │     
  │                                        │                                                         │ Working   │    
  └────────────────────────────────────────┴─────────────────────────────────────────────────────────┴───────────┘    

  ---
  What to Use Instead for Token Monitoring

  Since the Foundry list view token column is not supported for custom agents in Preview, use these instead:

  1. App Insights — Agents (Preview) view
  In Azure Portal → your App Insights → left menu → Agents (preview) — this gives a dedicated AI agent dashboard that 
  reads your gen_ai.* spans correctly.

  2. KQL — Daily Token Usage Dashboard
  dependencies
  | where timestamp > ago(30d)
  | where name == "create_agent"
  | where customDimensions["gen_ai.agents.id"] == "igentic-autonomous-agent"
  | summarize
      TotalRuns        = count(),
      TotalInputTokens  = sum(toint(customDimensions["gen_ai.usage.input_tokens"])),
      TotalOutputTokens = sum(toint(customDimensions["gen_ai.usage.output_tokens"]))
      by bin(timestamp, 1d)
  | order by timestamp desc

  3. Verify customMetrics extracted by App Insights
  customMetrics
  | where timestamp > ago(2h)
  | where name contains "gen_ai" or name contains "token"
  | project timestamp, name, value, customDimensions
  | order by timestamp desc

  ---
  Summary

  ┌─────────────────────────────┬───────────────────────────────────────────────────────────┬─────────────────────┐   
  │     What you're seeing      │                          Reason                           │  Can it be fixed?   │   
  ├─────────────────────────────┼───────────────────────────────────────────────────────────┼─────────────────────┤   
  │ List view shows             │ APIM root span name — Foundry's behavior                  │ ❌ No, by design    │    
  │ invoke_agent                │                                                           │                     │   
  ├─────────────────────────────┼───────────────────────────────────────────────────────────┼─────────────────────┤   
  │ List view Tokens = 0        │ Token usage column not supported for Custom agents        │ ❌ Not yet, Preview │    
  │                             │ (Preview limitation)                                      │  gap                │   
  ├─────────────────────────────┼───────────────────────────────────────────────────────────┼─────────────────────┤   
  │ Trace detail shows correct  │ Your code is working perfectly                            │ ✅ Already working  │    
  │ tokens                      │                                                           │                     │   
  ├─────────────────────────────┼───────────────────────────────────────────────────────────┼─────────────────────┤   
  │ App Insights shows correct  │ Full implementation correct                               │ ✅ Already working  │    
  │ data                        │                                                           │                     │   
  └─────────────────────────────┴───────────────────────────────────────────────────────────┴─────────────────────┘   

  Your code is 100% correct. The issue is a documented Preview limitation of Foundry's custom agent support, not a bug   in your implementation.

  Sources:
  - https://learn.microsoft.com/en-us/azure/ai-foundry/control-plane/how-to-manage-agents?view=foundry
  - https://learn.microsoft.com/en-us/azure/azure-monitor/app/agents-view
  - https://learn.microsoft.com/en-us/azure/ai-foundry/observability/concepts/trace-agent-concept?view=foundry  